package com.njitzx.controller;


import com.njitzx.entity.po.GoodsPics;
import com.njitzx.service.GoodsPicsService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.njitzx.entity.vo.Result;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import lombok.RequiredArgsConstructor;



import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 商品图片表 前端控制器
 * </p>
 *
 * @author 周鑫
 * @since 2024-08-20
 */
@Api(tags = "商品图片表接口")
@RestController
@RequestMapping("/goods-pics")
@RequiredArgsConstructor
public class GoodsPicsController {

    private final GoodsPicsService goodsPicsService;

    @ApiOperation("商品图片表分页查询")
    @GetMapping("/list")
    public Result findPage(@ApiParam("页码") @RequestParam(defaultValue = "1") Integer pageNum,
                               @ApiParam("页大小") @RequestParam(defaultValue = "5") Integer pageSize,
                               @ApiParam("查询条件") GoodsPics goodsPics){
        PageInfo<GoodsPics> pageInfo = goodsPicsService.findPage(pageNum,pageSize,goodsPics);
        return Result.success(pageInfo);
    }

    @ApiOperation("根据主键查询商品图片表")
    @GetMapping("/{picsId}")
    public Result findById(@PathVariable Serializable picsId){
        return Result.success(goodsPicsService.findById(picsId));
    }

    @ApiOperation("新增商品图片表")
    @PostMapping
    public Result add(@RequestBody GoodsPics goodsPics){
        goodsPicsService.add(goodsPics);
        return Result.success();
    }

    @ApiOperation("修改商品图片表")
    @PutMapping
    public Result modify(@RequestBody GoodsPics goodsPics){
        goodsPicsService.modify(goodsPics);
        return Result.success();
    }

    @ApiOperation("根据主键删除商品图片表")
    @DeleteMapping("/{picsId}")
    public Result removeById(@PathVariable Serializable picsId){
        goodsPicsService.removeById(picsId);
        return Result.success();
    }

}
